package com.mfangsoft.zhuangjialong.common.context;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.mfangsoft.zhuangjialong.common.model.Page;
import com.mfangsoft.zhuangjialong.common.utils.SysConstant;
import com.mfangsoft.zhuangjialong.common.utils.UserSessionUtil;

import com.mfangsoft.zhuangjialong.integration.enums.UserType;

import com.mfangsoft.zhuangjialong.integration.permission.model.PermissionEntity;
import com.mfangsoft.zhuangjialong.integration.user.model.UserEntity;
import com.mfangsoft.zhuangjialong.integration.user.model.UserInfoEntity;

public class UserContext {
	
	private final static Logger log = LoggerFactory.getLogger(UserContext.class);
	
	public  final static String USER_PERMISSION="user_permission";
	
	
	public  final static String CURRENT_USER_INFO="current_user_info";
	
	public  final static String PARENT_USER_INFO="PARENT_USER_INFO";
	
	
	public static UserEntity getCurrentUser(){
		
		
		
		return (UserEntity) UserSessionUtil.getUserSession().getAttribute(CURRENT_USER_INFO);
		
	}
	
	public static  Long  getCurrentUserId()
	{
		
		UserEntity userEntity=(UserEntity) UserSessionUtil.getUserSession().getAttribute(CURRENT_USER_INFO);
		
		return userEntity.getId();
		
	}
	
	public static List<PermissionEntity>  getCurrentPermission(){
		
		return (List<PermissionEntity>) UserSessionUtil.getUserSession().getAttribute(USER_PERMISSION);
		
		
	}
	
	
	public static UserInfoEntity getCurrentUserInfo()
	{
		
		UserEntity userEntity=(UserEntity) UserSessionUtil.getUserSession().getAttribute(CURRENT_USER_INFO);
		return userEntity.getUserInfoEntity();
	}
	
	
	

	

}
